/*******************************************************************************
 * 	Copyright 2016 ContainX and OpenStack4j                                          
 * 	                                                                                 
 * 	Licensed under the Apache License, Version 2.0 (the "License"); you may not      
 * 	use this file except in compliance with the License. You may obtain a copy of    
 * 	the License at                                                                   
 * 	                                                                                 
 * 	    http://www.apache.org/licenses/LICENSE-2.0                                   
 * 	                                                                                 
 * 	Unless required by applicable law or agreed to in writing, software              
 * 	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT        
 * 	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the         
 * 	License for the specific language governing permissions and limitations under    
 * 	the License.                                                                     
 *******************************************************************************/
package com.huawei.openstack4j.openstack.compute.domain;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.huawei.openstack4j.model.compute.FlavorAccess;
import com.huawei.openstack4j.openstack.common.ListResult;

import com.google.common.base.MoreObjects;

/**
 *
 * An OpenStack Flavor Access for tenants implement
 *
 * @author Moodpo
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class NovaFlavorAccess implements FlavorAccess {

	private static final long serialVersionUID = 1L;

	@JsonProperty("flavor_id")
	private String flavorId;

	@JsonProperty("tenant_id")
	private String tenantId;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getFlavorId() {
		return flavorId;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getTenantId() {
		return tenantId;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		return MoreObjects.toStringHelper(this).omitNullValues()
				.add("flavorId", flavorId).add("tenantId", tenantId)
				.addValue("\n").toString();
	}

	@JsonRootName("addTenantAccess")
	public static class AddTenantAccess extends NovaFlavorAccess {

		private static final long serialVersionUID = 1L;

		@JsonProperty("tenant")
		private String tenantId;

		public void setTenantId(String tenantId) {
			this.tenantId = tenantId;
		}

		public String getTenantId() {
			return tenantId;
		}

	}

	@JsonRootName("removeTenantAccess")
	public static class RemoveTenantAccess extends NovaFlavorAccess {

		private static final long serialVersionUID = 1L;

		@JsonProperty("tenant")
		private String tenantId;

		public void setTenantId(String tenantId) {
			this.tenantId = tenantId;
		}

		public String getTenantId() {
			return tenantId;
		}

	}

	public static class FlavorAccesses extends ListResult<NovaFlavorAccess> {

		private static final long serialVersionUID = 1L;

		@JsonProperty("flavor_access")
		List<NovaFlavorAccess> flavorAccesses;

		@Override
		protected List<NovaFlavorAccess> value() {
			return flavorAccesses;
		}

	}

}
